
package com.casstime.ec.cloud.meeting.web.config;

import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.boot.web.servlet.ErrorPage;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;

@Configuration
public class ErrorPageConfig implements EmbeddedServletContainerCustomizer {
	
	private static final String ERROR_PATH = "/error/";
	
	 @Override
	 public void customize(ConfigurableEmbeddedServletContainer container) {
		 container.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, ERROR_PATH + HttpStatus.NOT_FOUND.value()));	//404
		 container.addErrorPages(new ErrorPage(HttpStatus.UNAUTHORIZED, ERROR_PATH + HttpStatus.UNAUTHORIZED.value()));  //401
		 container.addErrorPages(new ErrorPage(HttpStatus.FORBIDDEN, ERROR_PATH + HttpStatus.FORBIDDEN.value()));	//403
		 container.addErrorPages(new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, ERROR_PATH + HttpStatus.INTERNAL_SERVER_ERROR.value()));	//500
		 container.addErrorPages(new ErrorPage(HttpStatus.METHOD_NOT_ALLOWED, ERROR_PATH + HttpStatus.METHOD_NOT_ALLOWED.value()));	//405
		 container.addErrorPages(new ErrorPage(HttpStatus.BAD_REQUEST, ERROR_PATH + HttpStatus.BAD_REQUEST.value()));	//400
		 container.addErrorPages(new ErrorPage(HttpStatus.BAD_GATEWAY, ERROR_PATH + HttpStatus.BAD_GATEWAY.value()));	//502
		 container.addErrorPages(new ErrorPage(HttpStatus.SERVICE_UNAVAILABLE, ERROR_PATH + HttpStatus.SERVICE_UNAVAILABLE.value()));	//503
		 container.addErrorPages(new ErrorPage(HttpStatus.GATEWAY_TIMEOUT, ERROR_PATH + HttpStatus.GATEWAY_TIMEOUT.value()));	//503
	 }
}